<script>
	import { getParkingIdByAppId } from '@/api/parking.js';
	import storage from "@/utils/storage";
	export default {
		onLaunch: function() {
			console.warn('当前组件仅支持 uni_modules 目录结构 ，请升级 HBuilderX 到 3.1.0 版本以上！')
			console.log('App Launch')
		},
		onShow: function() {
			console.log('App Show')
			this.getParkingIdByAppId();
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			getParkingIdByAppId(){
				uni.showLoading({
					title: '初始化',
					mask: true
				})
				// uni.hideTabBar()
				const appId = uni.getAccountInfoSync().miniProgram.appId;
				// const appId = 'wx405b1ada93945fd3'
				getParkingIdByAppId(appId)
				.then(res => {
					if(res.data.code == 0) {
						storage.setParkingId(res.data.data.parkingNo);
						
					} else {
						uni.hideTabBar();
						uni.showModal({
							title: '系统提示',
							content: '请检查当前车场是否已配置APPID'
						})
					}
				})
				.finally(() => {
					uni.hideLoading();
					// uni.showTabBar();
				})
			},
			/**
			 * 根据appID获取StoreId
			 */
			getStoreIdByAppId() {
				uni.showLoading({
					title: '初始化',
					mask: true
				})
				// uni.hideTabBar()
				const appId = uni.getAccountInfoSync().miniProgram.appId;
				// const appId = 'wx405b1ada93945fd3'
				getParkingIdByAppId(appId)
				.then(res => {
					if(res.data.code == 0) {
						storage.setParkingId(res.data.data.parkingNo);
						
					} else {
						uni.hideTabBar();
						uni.showModal({
							title: '系统提示',
							content: '请检查当前车场是否已配置APPID'
						})
					}
				})
				.finally(() => {
					uni.hideLoading();
					// uni.showTabBar();
				})
			},
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	@import '@/uni_modules/uni-scss/index.scss';
	/* #ifndef APP-NVUE */
	@import '@/static/customicons.css';
	
	/*每个页面公共css */
	@import "common/style/common.css";
	
	// 设置整个项目的背景色
	page {
		background-color: #f5f5f5;
	}

	/* #endif */
	.example-info {
		font-size: 14px;
		color: #333;
		padding: 10px;
	}
</style>
